/*
 * This file is part of the 京墨（jingmo）APP.
 *
 * (c) 贺丰宝（hefengbao） <hefengbao@foxmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

package com.hefengbao.jingmo.ui.screen.chinese.antitheticalcouplet

import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.viewModelScope
import com.hefengbao.jingmo.base.CaptureViewModel
import com.hefengbao.jingmo.data.repository.chinese.AntitheticalCoupletRepository
import com.hefengbao.jingmo.data.repository.settings.PreferenceRepository
import com.hefengbao.jingmo.data.repository.traditionalculture.ColorRepository
import com.hefengbao.jingmo.ui.screen.chinese.antitheticalcouplet.nav.AntitheticalCoupletCaptureArgs
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.stateIn
import javax.inject.Inject

@HiltViewModel
class AntitheticalCoupletCaptureViewModel @Inject constructor(
    savedStateHandle: SavedStateHandle,
    repository: AntitheticalCoupletRepository,
    colorRepository: ColorRepository,
    preferenceRepository: PreferenceRepository
) : CaptureViewModel(colorRepository, preferenceRepository) {
    private val args: AntitheticalCoupletCaptureArgs =
        AntitheticalCoupletCaptureArgs(savedStateHandle)

    val antitheticalCoupletEntity = repository.get(args.id.toInt()).stateIn(
        scope = viewModelScope,
        started = SharingStarted.WhileSubscribed(5_000),
        initialValue = null
    )
}